// https://iai.sh.cn/problem/561
#include <bits/stdc++.h>
using namespace std;
stack<char> st;
int main() {
  string s;
  cin >> s;
  // Remove unused variable
  // int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(' || s[i] == '[') {
      st.push(s[i]); // 入栈
    } else if (s[i] == ')' || s[i] == ']') {
      if (st.empty() || 
          (s[i] == ')' && st.top() != '(') || 
          (s[i] == ']' && st.top() != '[')) {
        cout << "Unbalanced";
        return 0;
      }
      st.pop(); // 出栈
    }
  }

  if (st.empty())
    cout << "Balanced";
  else
    cout << "Unbalanced";

  return 0;
}